package com.example.server;

import com.example.Product;
import com.example.mapper.ProductMapper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 产品service层
 *
 * @author sunhui
 */
@Service
public class ProductServiceImpl implements IProductService {

    /**
     * 产品mapper
     */
    @Resource
    private ProductMapper productMapper;

    /**
     * 测试接口-根据id查询产品
     *
     * @param id
     * @return
     */
    @Override
    public Product get(long id) {
        return productMapper.findById(id);
    }

    /**
     * 测试接口-添加产品
     *
     * @param product
     * @return
     */
    @Override
    public boolean add(Product product) {
        return productMapper.create(product);
    }


    /**
     * 测试接口-查询所有产品
     *
     * @return
     */
    @Override
    public List<Product> list() {
        return productMapper.findAll();
    }
}
